package com.andyage.admin.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.andyage.admin.bean.AdLogBean;
import com.andyage.admin.dao.AdLogMapper;
import com.andyage.admin.service.IAdLogService;
import com.andyage.util.JsonContent;
import com.google.gson.JsonObject;
@Service
public class AdLogServiceImpl implements IAdLogService {
	@Resource
	private AdLogMapper adlogMapper;
	@Override
	public String queryAdLogInfo(AdLogBean adlog) throws Exception {
		List<AdLogBean> list = adlogMapper.queryLogInfo(adlog);
		int total = adlogMapper.queryLogInfoCount(adlog);
		String json = JsonContent.getJsonArray(list, total);
		return json;
	}
	@Override
	public String deleteAdLogByLogId(List<String> list) throws Exception {
		int flag = adlogMapper.deleteLog(list);
		JsonObject json = new JsonObject();
		if(flag>0){
			json.addProperty("result", 1);
			json.addProperty("tips", "成功删除"+flag+"条");
		}else{
			json.addProperty("result", 0);
			json.addProperty("tips", "删除失败");
		}
		return json.toString();
	}

}
